﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using System.Diagnostics;

namespace DarwinIsDead.Traits {
    public class Transparency : Trait {

        public float opacityFloor;
        public float tempA;

        public Transparency(Zombie owner, World world = null)
         : base(owner, world) {
        }

        public override void Initialize() {
            Owner.Color.A = 255;  // set initial transparency to max.
            tempA = 255;
            opacityFloor = 13;
            Owner.MaxHealth += 4;
            Owner.HitBox.Height += 10;
            Owner.HitBox.Width += 10;
        }

        protected override void AdjustLevel(int level) {
            //opacityFloor -= 50;
        }

        /* May draw an outline of the zombie if I want to later 
        protected override void InternalDraw(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch, Microsoft.Xna.Framework.Color color) {
            base.InternalDraw(spriteBatch, color);
        }
         */

        protected override void InternalUpdate(GameTime gameTime) {
            float dt = (float)((float)gameTime.ElapsedGameTime.Milliseconds / 1000f);

            if (Owner.Color.A > opacityFloor) {
                tempA -= dt * 50;
            }
            //if (Owner.Color.A != 0) {
                Owner.Color.A = (byte)tempA;
                Owner.Color.R = (byte)tempA;
                Owner.Color.G = (byte)tempA;
                Owner.Color.B = (byte)tempA;
            //}
            Debug.WriteLine(Owner.Color.A);
        }

        public override object Clone() {
            return new Transparency(Owner, World);
        }

    }
}
